package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Company;
import com.example.Laboratory.Service.CompanyService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@RestController
@Api(value = "Company", description = "校企合作")
@RequestMapping(value = "/company")
@CrossOrigin
public class CompanyController {

    @Autowired
    CompanyService companyService;

    @ApiOperation(value = "添加校企合作", notes = "添加校企合作")
    @RequestMapping(value = "/addCompany", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addCompany (Company t) throws IOException {
        return ResultCode.SUCCESS.result(companyService.addCompany(t));
    }

    @ApiOperation(value = "删除校企合作接", notes = "删除校企合作")
    @RequestMapping(value = "/deleteCompany", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteUser (@RequestParam int company_id) throws IOException {
        return ResultCode.SUCCESS.result(companyService.deleteCompany(company_id));
    }

    @ApiOperation(value = "查找校企合作", notes = "查找校企合作")
    @RequestMapping(value = "/researchCompany", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectUser ( ) throws IOException {
        return ResultCode.SUCCESS.result(companyService.selectCompany());
    }

    @ApiOperation(value = "修改校企合作", notes = "修改校企合作")
    @RequestMapping(value = "/reviseFriendship", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateCompany (Company i) throws IOException {
        return ResultCode.SUCCESS.result(companyService.updateCompany(i));
    }
}
